package 多线程.线程池;

import java.util.concurrent.*;

public class 线程池常用方法 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService 线程池 = new ThreadPoolExecutor(3, 3, 8, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1),
                Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
        Future<String> future1 = 线程池.submit(new 多线程_实现callable接口(1));
        Future<String> future2 = 线程池.submit(new 多线程_实现callable接口(2));
        Future<String> future3 = 线程池.submit(new 多线程_实现callable接口(3));
        Future<String> future4 = 线程池.submit(new 多线程_实现callable接口(4));
        System.out.println(future1.get());
        System.out.println(future2.get());
        System.out.println(future3.get());
        System.out.println(future4.get());
    }
}
